import random;

class Activity(object):
    def __init__(self, stgm, sAct, aPersons, aTimes, nId):
        self.stgm = stgm;
        self.sActivity = sAct;
        self.aPersons = aPersons;
        self.aTimes = aTimes;
        self.sId = str(nId);
        self.nLikelihood = random.random();
    
#    def __init__(self, stgm):
#        self.stgm = stgm;
        
    def getKeyTexts(self):
        return [self.sActivity, self.aPersons];
    
    def addToGraph(self, graph, nPrior):
        sName = self.getNodeName();
        sObsId = self.sId+".1";
        obsName = sObsId+"-Obs_"+self.aTimes[0];
        self.rootAct = self.stgm.Node(sName, nId=self.sId, actName=self.sActivity, 
                                      aSubjects=self.aPersons, aTimes=self.aTimes, 
                                      score=self.nLikelihood, aObjects=[], location="");
        self.obsNode = self.stgm.Node(obsName, nId=sObsId, actName="Observation", 
                                      aSubjects=self.aPersons, aTimes=self.aTimes, 
                                      score=self.nLikelihood, aObjects=[], location="");
        graph.addnode(self.rootAct, [], nPrior);
        graph.addnode(self.obsNode, [self.rootAct], [self.nLikelihood]);
        graph.addobs(self.obsNode, True);
        
    def getNodeName(self):
        sPersons = "(";
        for i in range(len(self.aPersons)):
            if i==0: sPersons += self.aPersons[i];
            elif i>0: sPersons += ", " + self.aPersons[i];
        sPersons += ")"
        return self.sId+"-"+self.sActivity+"_"+self.aTimes[0]+"\\n"+sPersons;
    
    def makeNode(self):
        pass;